﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace _5.RealNumberValidator
{
    class Program
    {
        //"0", "33", "-2381.78132", "4.3347", "12.00", "0.34" 0, 0.00, are valid, but 
        //"+3", "24 543", "01.23", "12.", "11,23", "--2", ".25", "-.25" and "12е7" -0, 00, 00.00

        static void Main(string[] args)
        {
            string[] numbers = { "0", "33", "-2381.78132", "4.3347", "12.00", "0.34", "0", "0.00",
                                "+3", "24 543", "01.23", "12.", "11,23", "--2", ".25", "-.25",
                                "12е7", "-0", "00", "00.00"};
            foreach (var number in numbers)
            {
                ValidNumberChecker(number);
            }
        }

        public static void ValidNumberChecker(string number)
        {
            string integerNumberPattern = @"(\A(([-]?)([1-9][0-9]*)\Z)|(\A[0]\Z))";
            string doubleNumbers = @"(\A(([-]?)(0|([1-9][0-9]*)))[\.](([0-9]*[1-9])\Z))";
            string integerNumberEndingWithO = @"\A(0|[1-9]+)[\.]([0]*\Z)";

            Regex regex = new Regex(integerNumberPattern + "|" + doubleNumbers +
            "|" + integerNumberEndingWithO);

            bool isMatch = regex.IsMatch(number);
            string message = number + " is ";
            message = (isMatch) ? message + "match" : message + "not match";
            Console.WriteLine(message);
        }
    }
}
